package com.lzy.common.base;

/**
 * 基础异常
 * @author lyw
 * @Date 2023/2/2-下午1:52
 */
public class BaseException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    /**
     * 所属模块
     */
    private String module;

    /**
     * 错误码
     */
    private Integer status;

    /**
     * 错误码对应的参数
     */
    private Object[] args;

    /**
     * 错误消息
     */
    private String message;

    public BaseException() {}

    public BaseException(String module, Integer code, Object[] args, String defaultMessage)
    {
        this.module = module;
        this.status = code;
        this.args = args;
        this.message = defaultMessage;
    }

    public BaseException(String module, Integer code, Object[] args)
    {
        this(module, code, args, null);
    }
    public BaseException(String module, String defaultMessage, Integer code)
    {
        this(module, code, null, null);
    }

    public BaseException(String module, String defaultMessage)
    {
        this(module, null, null, defaultMessage);
    }

    public BaseException(Integer code, Object[] args)
    {
        this(null, code, args, null);
    }
    public BaseException(Integer code, String defaultMessage)
    {
        this(null, code, null, defaultMessage);
    }

    public BaseException(String defaultMessage)
    {
        this(null, null, null, defaultMessage);
    }

    @Override
    public String getMessage()
    {
        return message;
    }

    public String getModule()
    {
        return module;
    }

    public Integer getCode()
    {
        return status;
    }

    public Object[] getArgs()
    {
        return args;
    }
}
